#ifndef __UUCOMMANDPROCESS_H__
#define __UUCOMMANDPROCESS_H__
#include "stm32f7xx_hal.h"

#define UU_MODULECAN_MSGLEN		8	//UU一帧报文的长度

/* Message Type */
#define SETDATA 				0x00
#define SETDATA_RESPONSE 		0x01
#define READDATA 				0x02
#define READDATA_RESPONSE 		0x03
#define READ_SN_RESPONSE		0x04
#define ALL_SETDATA				0x0B
#define ALL_SETDATA_RESPONSE	0x0C


/* Command Type */
#define V_OUT 					0x00
#define I_OUT_SLOW				0x01
#define V_OUT_REFERENCE 		0x02
#define I_OUT_LIMIT 			0x03
#define START_STOP_MODULE		0x04
#define READ_SN					0x05
#define STATUS_FLAG				0x08
#define V_AB					0x14
#define V_BC					0x15
#define V_CA					0x16
#define VFAN_REFERENCE			0x1A
#define INLET_TEMPERATURE		0x1E
#define I_OUT_FASTEST			0x2F
#define I_OUT_FAST				0x30
#define GROUP_ADDRESS			0x59
#define HI_LO_Mode_SELECT		0x5F
#define HI_LO_Mode_STATUS		0x60
#define V_OUT_FAST				0x62
#define RT_HILO_STATUS			0x65
#define CURRENT_CAPABILITY		0x68
#define CURRENT_AND_CAPABILITY	0x72

//高/低压模式
#define HIGHVOL_MODE				0x01	//1000V
#define LOWVOL_MODE					0x02	//500V

#pragma pack(1)
//UULN Can协议报文帧ID联合体
typedef union
{
	uint32_t frameId;
	 struct
	{
		uint32_t serialNumPart:		9;
		uint32_t productionData:	5;
		uint32_t moduleAddress:		7;
		uint32_t monitorAddress:	4;
		uint32_t protocolVersion:	4;
		uint32_t unregist:			3;
	}bit;
}UU_ModuleFrameIdU;
#pragma pack()

uint8_t uuStart(uint8_t moduleAddr, uint8_t groupAddr, uint32_t sendData);		// 模块开机
uint8_t uuShutDown(uint8_t moduleAddr, uint8_t groupAddr, uint32_t sendData);	// 模块关机
uint8_t uuSetVout(uint8_t moduleAddr, uint8_t groupAddr,uint32_t setVoltage);	// 调压
uint8_t uuSetIout(uint8_t moduleAddr, uint8_t groupAddr, uint32_t setCurrent);	// 调流
uint8_t uuReadVout(uint8_t moduleAddr, uint8_t groupAddr, uint32_t sendData);	// 读取输出电压
uint8_t uuReadIout(uint8_t moduleAddr, uint8_t groupAddr, uint32_t sendData);	// 读取输出电流
uint8_t uuReadStatusFlag(uint8_t moduleAddr, uint8_t groupAddr, uint32_t sendData);	// 读取状态
uint8_t uuReadTemp(uint8_t moduleAddr, uint8_t groupAddr, uint32_t unRegistered);	// 读取温度
uint8_t uuReadVab(uint8_t moduleAddr, uint8_t groupAddr, uint32_t unRegistered);	// 读取三相电压Vab
uint8_t uuReadVbc(uint8_t moduleAddr, uint8_t groupAddr, uint32_t unRegistered);	// 读取三相电压Vbc
uint8_t uuReadVca(uint8_t moduleAddr, uint8_t groupAddr, uint32_t unRegistered);	// 读取三相电压Vca
uint8_t uuSetHiLoMode(uint8_t moduleAddr, uint8_t groupAddr, uint32_t sendData);	// 设置高/低压模式
uint8_t uuReadHiLoMode(uint8_t moduleAddr, uint8_t groupAddr, uint32_t readData);	// 读取高/低压模式
uint8_t uuSetGroupAddress(uint8_t moduleAddr, uint8_t groupAddr, uint32_t setGroupAddr);//设置模块分组

#endif //__UUCOMMANDPROCESS_H__
